<meta charset="utf-8">
<title>CSSNumericValue.equals tests</title>
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericvalue-equals">
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<script src="../../resources/testhelper.js"></script>
<script>
'use strict';

test(() => {
  assert_true(CSS.px(1).equals(CSS.px(1)));
}, 'Two CSSUnitValues with same value and unit are equal');

test(() => {
  assert_false(CSS.px(0).equals(CSS.px(1)));
}, 'Two CSSUnitValues with different values are not equal');

test(() => {
  assert_false(CSS.px(1).equals(CSS.number(1)));
}, 'Two CSSUnitValues with different units are not equal');

test(() => {
  const a = new CSSMathSum(0, new CSSMathNegate(0));
  const b = new CSSMathProduct(0, new CSSMathNegate(0));
  assert_false(a.equals(b));
}, 'Two CSSMathValues with different types are not equal');

test(() => {
  const a = new CSSMathSum(0, new CSSMathNegate(0));
  const b = new CSSMathSum(0);
  assert_false(a.equals(b));
}, 'Two CSSMathValues with different number of values are not equal');

test(() => {
  const a = new CSSMathSum(0, new CSSMathNegate(0));
  const b = new CSSMathSum(0, new CSSMathNegate(1));
  assert_false(a.equals(b));
}, 'Two CSSMathValues with different values are not equal');

test(() => {
  const a = new CSSMathSum(0, new CSSMathNegate(0));
  const b = new CSSMathSum(0, new CSSMathNegate(0));
  assert_true(a.equals(b));
}, 'Two CSSMathValues with same structure are equal');

test(() => {
  const a = new CSSMathSum(0, new CSSMathNegate(0));
  const b = new CSSMathSum(0, new CSSMathNegate(0));
  const c = new CSSMathSum(0, new CSSMathNegate(0));
  const d = new CSSMathSum(0, new CSSMathNegate(0));
  assert_true(a.equals(b, c, d));
}, 'Multiple CSSMathValues with same structure are equal');

test(() => {
  const a = new CSSMathSum(0, new CSSMathNegate(0));
  const b = new CSSMathSum(0, new CSSMathNegate(0));
  const c = new CSSMathSum(0, new CSSMathNegate(1));
  const d = new CSSMathSum(0, new CSSMathNegate(0));
  assert_false(a.equals(b, c, d));
}, 'Multiple CSSMathValues with one different are not equal');

test(() => {
  const a = new CSSMathClamp(1, 2, 3);
  const b = new CSSMathClamp(CSS.number(1), CSS.number(2), CSS.number(3));
  assert_true(a.equals(b));
}, 'Two CSSMathClamp with same value and unit are equal');

test(() => {
  const a = new CSSMathClamp(1, 2, 3);
  const b = new CSSMathClamp(CSS.px(1), CSS.px(2), CSS.px(3));
  assert_false(a.equals(b));
}, 'Two CSSMathClamp with different units are not equal');

</script>
